package com.ccr.roeun.moneymanager.app;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

import com.ccr.roeun.moneymanager.core.UnitOfMeasure;

import java.util.ArrayList;
import java.util.List;

public class UnitOfMeasureActivity extends Fragment implements AdapterView.OnItemClickListener {

    UnitOfMeasureAdapter adapter;
    ListView list;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView   = inflater.inflate(R.layout.unit_of_measure,container,false);

        List<UnitOfMeasure> uoms = new ArrayList<UnitOfMeasure>();
        for(int i=0;i<20;i++)
        {
            uoms.add(new UnitOfMeasure(0,null,null,"Item " + i,"abc"));
        }


        adapter = new UnitOfMeasureAdapter(container.getContext(),uoms);
        list=(ListView)rootView.findViewById(R.id.list);
        list.setAdapter(adapter);
        list.setOnItemClickListener(this);
        return rootView;
    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

        inflater.inflate(R.menu.main, menu);
        super.onCreateOptionsMenu(menu, inflater);
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        Toast.makeText(view.getContext(),"Item click " + position,Toast.LENGTH_SHORT).show();
    }

}
